package com.tanhua.dubbo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.pojo.TestQuestion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SoulQuestionMapper extends BaseMapper<TestQuestion> {

    @Select("SELECT * FROM (SELECT * FROM `tb_test_question` WHERE star <= #{star}) t1 " +
            "WHERE t1.id >= ((SELECT MAX(id) FROM `tb_test_question` WHERE star <= #{star})-(SELECT MIN(id) FROM `tb_test_question` WHERE star <= #{star}) - 10) * RAND() + (SELECT MIN(id) FROM `tb_test_question` WHERE star <= #{star}) LIMIT 10")
    List<TestQuestion> findRandomQuestion(@Param("star") Integer star);
}
